package paper.web.controller.paper;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import paper.domain.PaperArchive;
import paper.service.PaperQueryService;
import paper.service.PaperService;
import paper.web.controller.BaseController;

@Controller
@PreAuthorize("hasRole('TEACHER')")
@RequestMapping("/paper/paper/query")
public class PaperQueryController extends BaseController {
	
	@Autowired
	PaperService ps;
	
	@Autowired
	PaperQueryService pqs;
	
	
	/**
	 * Logger for this class
	 */
	private static final Logger logger = LoggerFactory.getLogger(PaperQueryController.class);
	
	public static class Views {
		private static final String Prefix = "paper/paper/query";
		static final String Index = to_(Prefix) + "index";
		static final String Add = to_(Prefix) + "add";
	}
	
	/**
	 * <p>Method ：login
	 * <p>Description : 处理控制台请求
	 * @return 
	 * @author  gulixing@msn.com
	 * @version 1.0.0
	 */
	@RequestMapping(value = Routes.Index, method = RequestMethod.GET)
	public String index(Model model) {
		return Views.Index;
	}
	
	
	@RequestMapping(value = "/getPaper", method = RequestMethod.GET)
	@ResponseBody
	public List<PaperArchive> getPaper() throws Exception {
		return pqs.findPaperArchive(getCurrentAccount().getUnit().getCode());
	}
	
}